<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>
    <div id="app">
        <cpn></cpn>
        <cpn ref="aaa"></cpn>
        <cpn ref="aaad"></cpn>
        <button @click="btnClick">按钮</button>
    </div>

    <template id="cpn">
        <h3>{{name}}</h3>
    </template>

    <script>
        //创建Vue实例,得到 ViewModel
        var vm = new Vue({
            el: '#app',
            data: {},
            methods: {
                btnClick() {
                    console.log(this.$children)
                    console.log(this.$refs)
                    this.$children[0].showMessage()
                }
            },
            components: {
                cpn: {
                    template: '#cpn',
                    methods: {
                        showMessage() {
                            console.log("ssss");
                        }
                    },
                    data() {
                        return {
                            name: "我是子组件1"
                        }
                    }
                }
            }
        });
    </script>
</body>

</html>